package org.the.gsdo.client;

import java.util.HashSet;
import java.util.Set;

import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.IsWidget;

public class CenterPanel extends DeckPanel implements AcceptsOneWidget {

	public Set<IsWidget> widgets = new HashSet<IsWidget>();

	public CenterPanel() {
		super();
		setWidth("100%");
	}

	@Override
	public void setWidget(IsWidget w) {
		if (w == null) {
			// noop; ActivityManager is doing this
		} else {
			if (! widgets.contains(w)) {
				super.add(w);
				widgets.add(w);
			}
			int idx = super.getWidgetIndex(w);
			super.showWidget(idx);
			if (w instanceof IsPlaceWidget) {
				((IsPlaceWidget)w).onShow();
			}
		}
	}
}
